package cn.edu.jnu.entity;

import cn.edu.jnu.GameWin;

import java.awt.*;

/**
 * 功能：敌方子弹
 * 作者：陈爱国
 * 日期：2024/8/13 11:13
 */
public class BulletObj extends GameObj{
    public BulletObj(Image img, int x, int y, int width, int height, double speed, GameWin frame) {
        super(img, x, y, width, height, speed, frame);
    }

    @Override
    public void paintSelf(Graphics gImage) {
        super.paintSelf(gImage);

        // 敌方子弹的移动
        y+=speed;

        // 我方飞机与敌方子弹的碰撞检测
        if (this.getRect().intersects(this.frame.planeObj.getRect())){
            // 改变游戏状态为未通关
            GameWin.state = 3;
        }
    }

    @Override
    public Rectangle getRect() {
        return super.getRect();
    }
}
